from common.basepage import BasePage
class Adduser(BasePage):
    def __init__(self,driver=None):
        super().__init__(driver)
        self.usernameLoc = 'id=account'
        self.realnameLoc = 'id=realname'
        self.sexmaloc = 'id=genderm'
        self.sexfeloc = 'id=genderf'
        self.departLoc = 'dept'
        self.roleLoc = 'id=role'
        self.passwordLoc = 'id=password1'
        self.repeatPassLoc = 'id=password2'
        self.emailLoc = 'id=email'
        self.submtloc='id=submit'
        self.backIframe = 'iframe-superadmin'
        self.assertSuccessLoc = 'xpath=/html/body/div/div/div/div[2]/div/div/div[1]/strong'
        self.assertLoc = "id=submit"
    def enter_username(self,name):
        self.input(self.usernameLoc,name)
    def enter_realname(self, name):
        self.input(self.realnameLoc, name)
    def click_sex(self,sex="man"):
        if sex=='man':
           self.click_button(self.sexmaloc)
        else:
            self.click_button(self.sexfeloc)
    def select_role(self,value='dev'):
        self.select_target_Value(self.roleLoc,value)
    def enter_password(self,password="66666666"):
        self.input(self.passwordLoc, password)
    def enter_repassword(self, repassword="66666666"):
        self.input(self.repeatPassLoc, repassword)
    def enter_email(self,emailValue):
        self.input(self.emailLoc, emailValue)
    def click_submit(self):
        self.click_button(self.submtloc)
    def enterBackIframe(self):
        self.enterIframe(self.backIframe)
    def get_assertSuccessText(self):
        return self.get_text(self.assertSuccessLoc)
    def get_assert_text(self):
        return self.get_text(self,self.assertLoc)